import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    loginname:sessionStorage.getItem('name'),  //登录用户信息
  },
  mutations: {
    updateLoginState(state,suibian){
      // 修改登录状态
      state.loginname = suibian
      // 将用户名存入sessionStorage,刷新网页依然存在
      sessionStorage.setItem('name',suibian)
    },
    logout(state){
      state.loginname = undefined
      sessionStorage.removeItem('name')  
    }
  },
  actions: {
  },
  modules: {
  }
})
